<template>
	<view :style="themeColor">
		<view class="page">
			<view
				class="flex benben-position-layout flex flex-wrap align-center toLearn_flex_0"
				:style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }"
			>
				<view class='flex flex-wrap align-center justify-between flex-sub toLearn_fd0_0'>
					<view
						class='flex flex-wrap align-center toLearn_fd0_0_c0'
						@tap.stop="handleJumpDiy"
						data-type="back"
						data-url="1"
					>
						<text class='fu-iconfont2  toLearn_fd0_0_c0_c0'>&#xE794;</text>
					</view>
					<view class='flex flex-wrap align-stretch justify-center'>
						<text
							class='toLearn_fd0_0_c1_c0'
							style="font-family: Alimama DongFangDaKai, Alimama DongFangDaKai;"
						>{{category_info.name}}</text>
					</view>
					<view class='flex flex-wrap align-center justify-end toLearn_fd0_0_c0'>
					</view>
				</view>

			</view>
			<view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
			<view
				class="loading_css"
				v-if="isShow"
			>
				<u-loading
					size="36"
					color="#AD3823"
				></u-loading>
				<view>加载中</view>
			</view>
			<block v-else>
				<!---flex布局flex布局开始-->
				<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout toLearn_flex_1">
					<view class='flex flex-direction flex-wrap align-stretch'>
						<view class='flex flex-direction flex-wrap align-stretch toLearn_fd1_0_c0'>
							<view class='flex flex-wrap align-center'>
								<text class='toLearn_fd1_0_c0_c0_c0'>{{category_info.name}}</text>
								<image
									@tap.stop="getCollect"
									class='toLearn_fd1_0_c0_c0_c1'
									mode="aspectFit"
									:src='STATIC_URL+"535.png"'
									v-if="category_info.is_collect == 0"
								></image>
								<image
									@tap.stop="getCollect"
									class='toLearn_fd1_0_c0_c0_c1'
									mode="aspectFit"
									:src='STATIC_URL+"544.png"'
									v-if="category_info.is_collect == 1"
								></image>
								<image
									class='toLearn_fd1_0_c0_c0_c2'
									mode="aspectFit"
									:src='STATIC_URL+"536.png"'
								></image>
							</view>
							<text class='toLearn_fd1_0_c0_c1'>{{category_info.nums}}位同学已购买</text>
						</view>

					</view>
					<view class='flex flex-direction flex-wrap align-stretch toLearn_fd1_0_c1'>
						<view class='flex flex-wrap align-center'>
							<text class='toLearn_fd1_0_c1_c0_c0'>开始学习</text>
						</view>
						<template v-for="(v, k) in course_list">
							<view
								class='flex flex-direction flex-wrap align-stretch toLearn_fd1_1'
								v-if="v.is_study == 1"
								:key="k"
							>
								<view
									class='flex align-center justify-between toLearn_fd1_0_c1_c1'
									@tap.stop="selectMonth(k)"
								>
									<text class='toLearn_fd1_0_c1_c0_c0'>第{{v.month}}个月</text>
									<image
										v-if="v.isOpen"
										class='toLearn_fd1_0_c1_c1_c1'
										mode="aspectFit"
										:src='STATIC_URL+"537.png"'
									></image>
									<image
										v-else
										class='toLearn_fd1_0_c1_c1_c1'
										mode="aspectFit"
										:src='STATIC_URL+"803.png"'
									></image>
								</view>
								<view
									class='flex flex-direction flex-wrap align-stretch'
									v-if="v.child.length > 0 && v.isOpen"
								>
									<view
										class='flex flex-wrap align-center toLearn_fd1_0_c1_c2_c0'
										v-for="(v1, k1) in v.child"
										:key="k1"
										@tap.stop="goStudy(v1)"
									>
										<text
											class='toLearn_fd1_0_c1_c2_c0_c0'
											v-if="k1 < 9"
										>0{{k1+1}}</text>
										<text
											class='toLearn_fd1_0_c1_c2_c0_c0'
											v-else
										>{{k1+1}}</text>
										<view class='flex flex-direction flex-wrap align-stretch toLearn_fd1_0_c1_c2_c0_c1'>
											<text class='toLearn_fd1_0_c1_c2_c0_c1_c0'>{{v1.name}}</text>
											<text class='toLearn_fd1_0_c1_c2_c0_c1_c1'>{{v1.nums}}位同学已学习</text>
										</view>
										<image
											v-if="v1.status == 0"
											class='toLearn_fd1_0_c1_c2_c0_c2'
											mode="aspectFit"
											:src='STATIC_URL+"534.png"'
										>
										</image>
										<image
											v-if="v1.status == 2"
											class='toLearn_fd1_0_c1_c2_c0_c2'
											mode="aspectFit"
											:src='STATIC_URL+"538.png"'
										>
										</image>
										<block v-if="v1.status == 1">
											<l-liquid
												:current.sync="modelVale"
												:percent="v.progress"
												size="40px"
												outline
											>
												<text style="font-size: 32rpx;color: #BAC67F;">{{v.progress}}</text>
												<text style="font-size: 24rpx;color: #BAC67F;">%</text>
											</l-liquid>
										</block>
									</view>

								</view>
							</view>
							<view
								class='flex flex-wrap align-center toLearn_fd1_2'
								v-else
								@tap.stop="popupShow1698289179736=true"
							>
								<text class='toLearn_fd1_0_c1_c0_c0'>第{{v.month}}个月</text>
								<image
									class='toLearn_fd1_0_c1_c2_c0_c2'
									mode="aspectFit"
									:src='STATIC_URL+"539.png"'
								></image>
							</view>
						</template>
					</view>

				</view>
			</block>

		</view>
		<benben-popup
			v-model="popupShow1698289179736"
			:mask="true"
			:mask-close-able="true"
			mode='center'
			:z-index='999'
		>
			<!---flex布局flex布局开始-->
			<view class="flex benben-flex-layout flex-wrap align-center">
				<view class='flex flex-direction flex-wrap align-stretch buyOffline_fd3_0'>
					<view class='flex flex-direction flex-wrap align-center'>
						<text class='buyOffline_fd3_0_c0_c0'>您好，同学</text>
						<text class='buyOffline_fd3_0_c0_c1'>当前阶段暂未解锁
							请解锁后再继续学习</text>
						<view class='flex flex-wrap align-center buyOffline_fd3_0_c0_c2'>
							<view
								class='flex flex-wrap align-center justify-center buyOffline_fd3_0_c0_c2_c0'
								@tap.stop="popupShow1698289179736=false"
							>
								<text class='buyOffline_fd3_0_c0_c2_c0_c0'>取消</text>
							</view>
							<view
								class='flex flex-wrap align-center justify-center buyOffline_fd3_0_c0_c2_c1'
								@tap.stop="popupShow1698289179736=false"
							>
								<text class='buyOffline_fd3_0_c0_c2_c1_c0'>确认</text>
							</view>
						</view>
					</view>
				</view>
			</view>
		</benben-popup>
	</view>
</template>
<script>
	export default {
		components: {},


		data() {
			return {
				aid: "",
				isShow: true,
				course_list: [],
				category_info: {},
				modelVale: 0,
				popupShow1698289179736: false,
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},

		},
		watch: {},
		onLoad(options) {
			let { aid } = options;
			if (aid !== undefined) this.aid = aid;
			this.getData();
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			// 获取章节列表  65556df43a06c
			getData() {
				this.$api.post(global.API_VERSION + '65556df43a06c', {
					category_id: this.aid,
					order_sn: global.course_order
				}).then(res => {
					// console.log(res);
					this.isShow = false;
					if (res.data.code == 1) {
						this.course_list = res.data.data.course_list;
						this.category_info = res.data.data.category_info;
						if (this.course_list.length > 0) {
							this.course_list.forEach((v, k) => {
								v.isOpen = false;
							})
						}
					} else {
						this.$message.info(res.data.msg);
					}
				})
			},
			// 收藏  65557b142eaf9
			getCollect() {
				this.$api.post(global.API_VERSION + '65557b142eaf9', {
					category_id: this.aid
				}).then(res => {
					this.$message.info(res.data.msg);
					if (res.data.code == 1) {
						if (res.data.data == 1) {
							this.category_info.is_collect = 1;
						} else {
							this.category_info.is_collect = 0;
						}
					}
				})
			},
			selectMonth(index) {
				this.course_list[index].isOpen = !this.course_list[index].isOpen;
				this.$forceUpdate();
			},

			// 去学习  
			goStudy(item) {
				console.log(item);
				uni.navigateTo({
					url: '/pages/shouye/study/study?aid=' + item.aid + '&data_type=' + item.data_type
				})
			}
		}
	};
</script>
<style
	lang="scss"
	scoped
>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: url(https://www.guochaoxiaoju.com/uploads/mini/520.png) no-repeat;
		background-size: 100% auto;
	}

	.toLearn_flex_0 {
		background: url(https://www.guochaoxiaoju.com/uploads/mini/520.png) no-repeat;
		width: 750rpx;
		height: 88rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.toLearn_fd0_0_c1_c0 {
		font-size: 40rpx;
		font-weight: 400;
		color: #FFFFFF;
		line-height: 88rpx;
	}

	.toLearn_fd0_0_c0_c0 {
		font-size: 36rpx;
		color: var(--benbenFontColor3);
	}

	.toLearn_fd0_0_c0 {
		width: 120rpx;
	}

	.toLearn_fd0_0 {
		padding: 0rpx 32rpx 0rpx 32rpx;
	}

	.toLearn_flex_1 {
		padding: 48rpx 30rpx 0rpx 30rpx;
	}

	.toLearn_fd1_2 {
		background: #FFFFFF;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		padding: 24rpx;
		margin: 24rpx 0rpx 0rpx 0rpx;
	}

	.toLearn_fd1_1 {
		background: #FFFFFF;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		padding: 0rpx 24rpx 0rpx 24rpx;
		margin: 0rpx 0rpx 24rpx 0rpx;
	}

	.toLearn_fd1_0_c1_c2_c1_c1_c0_c1_c0 {
		color: #FFFFFF;
		font-size: 22rpx;
		font-weight: 400;
	}

	.toLearn_fd1_0_c1_c2_c1_c1_c0_c1 {
		background: linear-gradient(90deg, #BB4834 0%, #96301D 100%);
		border-radius: 30rpx;
		margin: 0rpx 0rpx 0rpx 16rpx;
		padding: 6rpx 10rpx 6rpx 10rpx;
	}

	.toLearn_fd1_0_c1_c2_c0_c2 {
		width: 78rpx;
		height: 78rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		margin: 0rpx 0rpx 0rpx auto;
	}

	.toLearn_fd1_0_c1_c2_c0_c1_c1 {
		color: #333333;
		font-size: 28rpx;
		font-weight: 400;
		margin: 19rpx 0rpx 0rpx 0rpx;
	}

	.toLearn_fd1_0_c1_c2_c0_c1_c0 {
		color: #333333;
		font-size: 40rpx;
		font-weight: 400;
	}

	.toLearn_fd1_0_c1_c2_c0_c1 {
		margin: 0rpx 0rpx 0rpx 24rpx;
	}

	.toLearn_fd1_0_c1_c2_c0_c0 {
		color: #333333;
		font-size: 64rpx;
		font-weight: 400;
	}

	.toLearn_fd1_0_c1_c2_c0 {
		border-bottom: 1px solid rgba(221, 221, 221, 1);
		padding: 32rpx 0rpx 32rpx 5rpx;
	}

	.toLearn_fd1_0_c1_c1_c1 {
		width: 30rpx;
		height: 30rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		// margin: 0rpx 0rpx 0rpx auto;
	}

	.toLearn_fd1_0_c1_c1 {
		padding: 30rpx 0rpx 0rpx 0rpx;
	}

	.toLearn_fd1_0_c1_c0_c0 {
		color: #333333;
		font-size: 48rpx;
		font-weight: 400;
	}

	.toLearn_fd1_0_c1 {
		background: #FFFFFF;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		padding: 32rpx 24rpx 32rpx 24rpx;
		margin: 0rpx 0rpx 24rpx 0rpx;
	}

	.toLearn_fd1_0_c0_c1 {
		color: #999999;
		font-size: 32rpx;
		font-weight: 400;
		margin: 15rpx 0rpx 0rpx 0rpx;
	}

	.toLearn_fd1_0_c0_c0_c2 {
		width: 44rpx;
		height: 44rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
	}

	.toLearn_fd1_0_c0_c0_c1 {
		width: 44rpx;
		height: 44rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		margin: 0rpx 22rpx 0rpx auto;
	}

	.toLearn_fd1_0_c0_c0_c0 {
		color: #AD3823;
		font-size: 48rpx;
		font-weight: 400;
		text-shadow: 2rpx 2rpx 4rpx rgba(161, 55, 35, 0.16);
	}

	.toLearn_fd1_0_c0 {
		background: #FFFFFF;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		padding: 25rpx 24rpx 34rpx 24rpx;
		margin: 0rpx 0rpx 24rpx 0rpx;
	}

	.buyOffline_fd3_0_c0_c2_c1_c0 {
		color: #FFFFFF;
		font-size: 34rpx;
		font-weight: 400;
	}

	.buyOffline_fd3_0_c0_c2_c1 {
		background: url(https://www.guochaoxiaoju.com/uploads/mini/694.png) no-repeat;
		height: 71rpx;
		width: 191rpx;
		margin: 0rpx 0rpx 0rpx 16rpx;
		background-size: 100% auto;
	}

	.buyOffline_fd3_0_c0_c2_c0_c0 {
		color: #796446;
		font-size: 34rpx;
		font-weight: 400;
	}

	.buyOffline_fd3_0_c0_c2_c0 {
		background: url(https://www.guochaoxiaoju.com/uploads/mini/693.png) no-repeat;
		height: 71rpx;
		width: 191rpx;
		margin: 0rpx 16rpx 0rpx 0rpx;
		background-size: 100% auto;
	}

	.buyOffline_fd3_0_c0_c2 {
		margin: 0rpx 0rpx 70rpx 0rpx;
	}

	.buyOffline_fd3_0_c0_c1 {
		line-height: 44rpx;
		font-size: 32rpx;
		font-weight: 400;
		color: #333333;
		margin: 40rpx 0rpx 35rpx 0rpx;
		text-align: center;
	}

	.buyOffline_fd3_0_c0_c0 {
		color: #333333;
		font-size: 40rpx;
		font-weight: 400;
		margin: 190rpx 0rpx 0rpx 0rpx;
	}

	.buyOffline_fd3_0 {
		background: url(https://www.guochaoxiaoju.com/uploads/mini/692.png) no-repeat;
		width: 580rpx;
		background-size: 100% auto;
	}
</style>

<style>
	page {
		font-family: Alimama DongFangDaKai;
	}
</style>